import { _decorator, RichText } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('LocalizedRichText')
export class LocalizedRichText extends RichText {
    @property({ serializable: false, override: true })
    protected _string = '';

    @property({ serializable: true })
    private _textId = '<color=#00ff00>Rich</color><color=#0fffff>Text</color>';

    @property({ multiline: true, displayOrder: -1})
    get textId() {
        return this._textId;
    }
    set textId(value: string) {
        if (value) {
            value += '';
        } else {
            value = '';
        }
        if (this._textId === value) {
            return;
        }
        this._textId = value;
        this.applyTextId();
    }

    private applyTextId() {
        this.string = this._textId;
    }

    public onEnable() {
        this.applyTextId();
        super.onEnable();
    }

    public onDisable() {
        super.onDisable();
    }
}
